package com.bookstore.back.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bookstore.back.entity.ReviewLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ReviewLikeMapper extends BaseMapper<ReviewLike> {

    @Select("SELECT COUNT(*) FROM review_likes WHERE review_id = #{reviewId} AND user_id = #{userId}")
    int checkUserLiked(@Param("reviewId") Integer reviewId, @Param("userId") Integer userId);

    @Select("SELECT COUNT(*) FROM review_likes WHERE review_id = #{reviewId}")
    int getReviewLikeCount(@Param("reviewId") Integer reviewId);

}
